{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "89b0198b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d138e53e",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_change=np.random.normal(0,1,(10,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0341db0a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2.89916690e-01,  1.18853834e+00, -3.25571749e-01,\n",
       "         8.38424478e-01,  2.28431050e-02],\n",
       "       [-3.13858827e-01,  5.18475684e-01,  1.10101533e-01,\n",
       "        -1.07095916e-01, -5.50816836e-01],\n",
       "       [-5.47705407e-01,  3.72907578e-01,  1.74828491e-01,\n",
       "         1.43092877e-01, -1.39027829e+00],\n",
       "       [ 1.29548196e-03,  4.54184657e-01,  8.28516181e-01,\n",
       "         7.28889428e-01,  1.25000780e-01],\n",
       "       [-1.13559025e+00, -5.84973073e-01, -8.93092451e-01,\n",
       "        -3.98545010e-01, -1.22228832e+00],\n",
       "       [-1.31081710e+00, -4.70119908e-01,  3.66073813e-01,\n",
       "        -5.31122539e-01,  8.02977818e-02],\n",
       "       [-4.45220821e-01,  7.98373251e-01, -8.00356047e-02,\n",
       "        -9.80186538e-01,  1.05907812e+00],\n",
       "       [-6.74122619e-01,  4.45683311e-01,  3.53116011e-01,\n",
       "         3.16150082e-01, -3.85868114e-01],\n",
       "       [-2.86241763e-01, -1.23691377e+00,  2.54945926e+00,\n",
       "         7.94826852e-01,  1.27365857e+00],\n",
       "       [ 9.94968907e-01,  4.21979422e-01, -1.79422252e+00,\n",
       "        -1.27924256e+00, -4.75318980e-01]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_change"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5602e471",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_rise=pd.DataFrame(stock_change)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "129a4942",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_rise.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "23c40252",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_code=[\"股票{}\".format(i+1) for i in range(stock_rise.shape[0])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "0534f731",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['股票1', '股票2', '股票3', '股票4', '股票5', '股票6', '股票7', '股票8', '股票9', '股票10']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "42d00539",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>0.289917</td>\n",
       "      <td>1.188538</td>\n",
       "      <td>-0.325572</td>\n",
       "      <td>0.838424</td>\n",
       "      <td>0.022843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>-0.313859</td>\n",
       "      <td>0.518476</td>\n",
       "      <td>0.110102</td>\n",
       "      <td>-0.107096</td>\n",
       "      <td>-0.550817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>-0.547705</td>\n",
       "      <td>0.372908</td>\n",
       "      <td>0.174828</td>\n",
       "      <td>0.143093</td>\n",
       "      <td>-1.390278</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>0.001295</td>\n",
       "      <td>0.454185</td>\n",
       "      <td>0.828516</td>\n",
       "      <td>0.728889</td>\n",
       "      <td>0.125001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票5</th>\n",
       "      <td>-1.135590</td>\n",
       "      <td>-0.584973</td>\n",
       "      <td>-0.893092</td>\n",
       "      <td>-0.398545</td>\n",
       "      <td>-1.222288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票6</th>\n",
       "      <td>-1.310817</td>\n",
       "      <td>-0.470120</td>\n",
       "      <td>0.366074</td>\n",
       "      <td>-0.531123</td>\n",
       "      <td>0.080298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票7</th>\n",
       "      <td>-0.445221</td>\n",
       "      <td>0.798373</td>\n",
       "      <td>-0.080036</td>\n",
       "      <td>-0.980187</td>\n",
       "      <td>1.059078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票8</th>\n",
       "      <td>-0.674123</td>\n",
       "      <td>0.445683</td>\n",
       "      <td>0.353116</td>\n",
       "      <td>0.316150</td>\n",
       "      <td>-0.385868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票9</th>\n",
       "      <td>-0.286242</td>\n",
       "      <td>-1.236914</td>\n",
       "      <td>2.549459</td>\n",
       "      <td>0.794827</td>\n",
       "      <td>1.273659</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票10</th>\n",
       "      <td>0.994969</td>\n",
       "      <td>0.421979</td>\n",
       "      <td>-1.794223</td>\n",
       "      <td>-1.279243</td>\n",
       "      <td>-0.475319</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             0         1         2         3         4\n",
       "股票1   0.289917  1.188538 -0.325572  0.838424  0.022843\n",
       "股票2  -0.313859  0.518476  0.110102 -0.107096 -0.550817\n",
       "股票3  -0.547705  0.372908  0.174828  0.143093 -1.390278\n",
       "股票4   0.001295  0.454185  0.828516  0.728889  0.125001\n",
       "股票5  -1.135590 -0.584973 -0.893092 -0.398545 -1.222288\n",
       "股票6  -1.310817 -0.470120  0.366074 -0.531123  0.080298\n",
       "股票7  -0.445221  0.798373 -0.080036 -0.980187  1.059078\n",
       "股票8  -0.674123  0.445683  0.353116  0.316150 -0.385868\n",
       "股票9  -0.286242 -1.236914  2.549459  0.794827  1.273659\n",
       "股票10  0.994969  0.421979 -1.794223 -1.279243 -0.475319"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(stock_change,index=stock_code)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "eea0b0e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "date=pd.date_range(start=\"20211014\",periods=stock_rise.shape[1],freq=\"B\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "6910a3af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2021-10-14', '2021-10-15', '2021-10-18', '2021-10-19',\n",
       "               '2021-10-20'],\n",
       "              dtype='datetime64[ns]', freq='B')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ef17dac5",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_c=pd.DataFrame(stock_change,index=stock_code,columns=date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "96e74d11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['股票1', '股票2', '股票3', '股票4', '股票5', '股票6', '股票7', '股票8', '股票9', '股票10'], dtype='object')"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_c.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b2fc06d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2.89916690e-01,  1.18853834e+00, -3.25571749e-01,\n",
       "         8.38424478e-01,  2.28431050e-02],\n",
       "       [-3.13858827e-01,  5.18475684e-01,  1.10101533e-01,\n",
       "        -1.07095916e-01, -5.50816836e-01],\n",
       "       [-5.47705407e-01,  3.72907578e-01,  1.74828491e-01,\n",
       "         1.43092877e-01, -1.39027829e+00],\n",
       "       [ 1.29548196e-03,  4.54184657e-01,  8.28516181e-01,\n",
       "         7.28889428e-01,  1.25000780e-01],\n",
       "       [-1.13559025e+00, -5.84973073e-01, -8.93092451e-01,\n",
       "        -3.98545010e-01, -1.22228832e+00],\n",
       "       [-1.31081710e+00, -4.70119908e-01,  3.66073813e-01,\n",
       "        -5.31122539e-01,  8.02977818e-02],\n",
       "       [-4.45220821e-01,  7.98373251e-01, -8.00356047e-02,\n",
       "        -9.80186538e-01,  1.05907812e+00],\n",
       "       [-6.74122619e-01,  4.45683311e-01,  3.53116011e-01,\n",
       "         3.16150082e-01, -3.85868114e-01],\n",
       "       [-2.86241763e-01, -1.23691377e+00,  2.54945926e+00,\n",
       "         7.94826852e-01,  1.27365857e+00],\n",
       "       [ 9.94968907e-01,  4.21979422e-01, -1.79422252e+00,\n",
       "        -1.27924256e+00, -4.75318980e-01]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_c.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7bf32bc5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>股票1</th>\n",
       "      <th>股票2</th>\n",
       "      <th>股票3</th>\n",
       "      <th>股票4</th>\n",
       "      <th>股票5</th>\n",
       "      <th>股票6</th>\n",
       "      <th>股票7</th>\n",
       "      <th>股票8</th>\n",
       "      <th>股票9</th>\n",
       "      <th>股票10</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-10-14</th>\n",
       "      <td>0.289917</td>\n",
       "      <td>-0.313859</td>\n",
       "      <td>-0.547705</td>\n",
       "      <td>0.001295</td>\n",
       "      <td>-1.135590</td>\n",
       "      <td>-1.310817</td>\n",
       "      <td>-0.445221</td>\n",
       "      <td>-0.674123</td>\n",
       "      <td>-0.286242</td>\n",
       "      <td>0.994969</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-15</th>\n",
       "      <td>1.188538</td>\n",
       "      <td>0.518476</td>\n",
       "      <td>0.372908</td>\n",
       "      <td>0.454185</td>\n",
       "      <td>-0.584973</td>\n",
       "      <td>-0.470120</td>\n",
       "      <td>0.798373</td>\n",
       "      <td>0.445683</td>\n",
       "      <td>-1.236914</td>\n",
       "      <td>0.421979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-18</th>\n",
       "      <td>-0.325572</td>\n",
       "      <td>0.110102</td>\n",
       "      <td>0.174828</td>\n",
       "      <td>0.828516</td>\n",
       "      <td>-0.893092</td>\n",
       "      <td>0.366074</td>\n",
       "      <td>-0.080036</td>\n",
       "      <td>0.353116</td>\n",
       "      <td>2.549459</td>\n",
       "      <td>-1.794223</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-19</th>\n",
       "      <td>0.838424</td>\n",
       "      <td>-0.107096</td>\n",
       "      <td>0.143093</td>\n",
       "      <td>0.728889</td>\n",
       "      <td>-0.398545</td>\n",
       "      <td>-0.531123</td>\n",
       "      <td>-0.980187</td>\n",
       "      <td>0.316150</td>\n",
       "      <td>0.794827</td>\n",
       "      <td>-1.279243</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-20</th>\n",
       "      <td>0.022843</td>\n",
       "      <td>-0.550817</td>\n",
       "      <td>-1.390278</td>\n",
       "      <td>0.125001</td>\n",
       "      <td>-1.222288</td>\n",
       "      <td>0.080298</td>\n",
       "      <td>1.059078</td>\n",
       "      <td>-0.385868</td>\n",
       "      <td>1.273659</td>\n",
       "      <td>-0.475319</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 股票1       股票2       股票3       股票4       股票5       股票6  \\\n",
       "2021-10-14  0.289917 -0.313859 -0.547705  0.001295 -1.135590 -1.310817   \n",
       "2021-10-15  1.188538  0.518476  0.372908  0.454185 -0.584973 -0.470120   \n",
       "2021-10-18 -0.325572  0.110102  0.174828  0.828516 -0.893092  0.366074   \n",
       "2021-10-19  0.838424 -0.107096  0.143093  0.728889 -0.398545 -0.531123   \n",
       "2021-10-20  0.022843 -0.550817 -1.390278  0.125001 -1.222288  0.080298   \n",
       "\n",
       "                 股票7       股票8       股票9      股票10  \n",
       "2021-10-14 -0.445221 -0.674123 -0.286242  0.994969  \n",
       "2021-10-15  0.798373  0.445683 -1.236914  0.421979  \n",
       "2021-10-18 -0.080036  0.353116  2.549459 -1.794223  \n",
       "2021-10-19 -0.980187  0.316150  0.794827 -1.279243  \n",
       "2021-10-20  1.059078 -0.385868  1.273659 -0.475319  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_c.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f9670261",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021-10-14</th>\n",
       "      <th>2021-10-15</th>\n",
       "      <th>2021-10-18</th>\n",
       "      <th>2021-10-19</th>\n",
       "      <th>2021-10-20</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>0.289917</td>\n",
       "      <td>1.188538</td>\n",
       "      <td>-0.325572</td>\n",
       "      <td>0.838424</td>\n",
       "      <td>0.022843</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2021-10-14  2021-10-15  2021-10-18  2021-10-19  2021-10-20\n",
       "股票1    0.289917    1.188538   -0.325572    0.838424    0.022843"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_c.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "c3bcd77d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021-10-14</th>\n",
       "      <th>2021-10-15</th>\n",
       "      <th>2021-10-18</th>\n",
       "      <th>2021-10-19</th>\n",
       "      <th>2021-10-20</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票10</th>\n",
       "      <td>0.994969</td>\n",
       "      <td>0.421979</td>\n",
       "      <td>-1.794223</td>\n",
       "      <td>-1.279243</td>\n",
       "      <td>-0.475319</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      2021-10-14  2021-10-15  2021-10-18  2021-10-19  2021-10-20\n",
       "股票10    0.994969    0.421979   -1.794223   -1.279243   -0.475319"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_c.tail(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "84496bb1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
